/*
 * Copyright (c) 2020, chao
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-08-21     chao         the first version
 */

#include "emxgui.h"
#include "gui_demo.h"


LRESULT status_bar_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    
    switch (msg)
    {
    case WM_CREATE:
        return TRUE;

    case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc;
        RECT rc;
        
        hdc =BeginPaint(hwnd,&ps);
        GetClientRect(hwnd, &rc);
        //rc.w /= 2;
        SetBrushColor(hdc,MapRGB(hdc,0,200,0));
        DrawText(hdc, L"2020-09-10 17:00", -1, &rc, DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_BKGND);
        EndPaint(hwnd,&ps);
        break;
    }
        
    default:
        return DefDesktopProc(hwnd, msg, wParam, lParam);
    }
    return WM_NULL;
}

void gui_demo_status_bar(void)
{
    HWND hwnd;
    WNDCLASS wcex;
    MSG msg;

    wcex.Tag = WNDCLASS_TAG;
    wcex.Style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = status_bar_proc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = NULL;
    wcex.hIcon = NULL;
    wcex.hCursor = NULL;

    hwnd = CreateWindowEx(WS_EX_LOCKPOS, &wcex, L"Status Bar", 
    WS_VISIBLE|WS_CLIPCHILDREN, 
    0, 0, GUI_XSIZE, STATUS_BAR_HEIGHT, NULL, 0, NULL, NULL);

    ShowWindow(hwnd, SW_SHOW);

    while (GetMessage(&msg, hwnd))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}

